package zlx.service.Impl;

import org.springframework.stereotype.Service;
import zlx.mapper.UserMapper;
import zlx.pojo.User;
import zlx.service.UserService;

import javax.annotation.Resource;
import javax.jms.MessageEOFException;

@Service(value = "userService")
public class UserServiceImpl implements UserService{
    @Resource
    private UserMapper userMapper;
    @Override
    public User CheckLoginInfo(User user) throws Exception {
        User userInfo = userMapper.selectUserByNameAndPassword(user);
        if(userInfo==null){
            throw new MessageEOFException("用户名或密码错误");
        }
        return userInfo;
    }
    //用户注册。把数据存到数据库
    @Override
    public void userRegist(User user) {
        userMapper.InsertUserInfo(user);
    }

    //根据用户名查找用户
    @Override
    public User checkUserByUsername(String username) {
        return userMapper.selectUserByUserName(username);
    }
}
